<?php
/**
 * Print a track list in a table.
 * 
 * @$head	The first line (table header)
 * @$data	a bidirectional table contening the lines MUST contains a row ALBUM_NO and TRACK_NO !
 * @$keys	the rows to print
 * @$count	the number of lines
 */
function track_list(array $head, array $data, array $keys, $count) {

	echo "<form method=\"POST\" action=\"queue.php\">\n";
	echo "	<table class=\"tracks\">\n";
	
	// table header
	echo "		<tr>";
	for($c = 0; $c < sizeof($head); $c++)
		echo "<th>".$head[$c]."</th>";
	if(strtolower($_SESSION["USERNAME"]) != "guest") 
		echo "<th><input name=\"checkallinput\" type=\"checkbox\" onClick=\"checkall(this.form, this.checked);\" /></th>";
	echo "</tr>\n";

	// lines
	for($l = 0; $l < $count; $l++) {
		echo "<tr".($l%2 ? " class=\"pairLine\"" : " class=\"oddLine\"").">";
		for($c = 0; $c < sizeof($head); $c++) {
			if($keys[$c] == "TITLE")
				echo "<td><a href=\"albums.php?album=".$data["$l"]["ALBUM_NO"]."&amp;track=".$data["$l"]["TRACK_NO"]."\">".$data[$l][$keys[$c]]."</a></td>";
			else
				echo "<td>".$data[$l][$keys[$c]]."</td>";
		}
		if(strtolower($_SESSION["USERNAME"]) != "guest")
			echo "<td><input type=\"checkbox\" name=\"select[]\" value=\"".$data["$l"]["ALBUM_NO"].",".$data["$l"]["TRACK_NO"]."\" /></td>";
		echo "</tr>\n";
		
	}

	echo "	</table>\n";
	echo "	<p><input type=\"submit\" value=\""._("Queue selected songs")."\"/> --- <select name=\"rate\"><option value=\"AWFUL\">"._("AWFUL")."</option><option value=\"BAD\">"._("BAD")."</option><option value=\"NEUTRAL\" selected>"._("NEUTRAL")."</option><option value=\"GOOD\">"._("GOOD")."</option><option value=\"SUPERB\">"._("SUPERB")."</option></select><input type=\"button\" value=\""._("Rate")."\" onclick=\"submitRateTrack(this.form)\"/></p>\n";
	echo "</form>\n";
}

?>
